home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / System7 tools / Frontier / Frontier SDK 2.1 / Toolkits / IAC Tools / iacops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-03  |  2.1 KB  |  108 lines  |  [TEXT/KAHL]

  1.  
  2. /*© Copyright 1988-1992 UserLand Software, Inc.  All Rights Reserved.*/
  3.  
  4. #include "iacinternal.h"
  5.  
  6.  
  7. void IACcopystring (void *source, void *dest) {
  8.  
  9.     /*
  10.     create a copy of source in dest.  copy the length byte and
  11.     all the characters in the source string.
  12.  
  13.     assume the strings are pascal strings, with the length byte in
  14.     the first character of the string.
  15.     */
  16.     
  17.     register char *s = source, *d = dest;
  18.     register short i, len;
  19.     
  20.     len = (short) s [0];
  21.     
  22.     for (i = 0; i <= len; i++) 
  23.         *d++ = *s++;
  24.     } /*IACcopystring*/
  25.  
  26.  
  27. Boolean IACpushstring (void *source, void *dest) {
  28.  
  29.     /*
  30.     insert the source string at the end of the destination string.
  31.     
  32.     assume the strings are pascal strings, with the length byte in
  33.     the first character of the string.
  34.     */
  35.     
  36.     register char *s = source, *d = dest;
  37.     register short lensource = s [0];
  38.     register short lendest = d [0];
  39.     register short newlen = lensource + lendest;
  40.     
  41.     if (newlen > 255)
  42.         return (false);
  43.         
  44.     d [0] = (char) newlen;
  45.     
  46.     d += (char) lendest + 1; /*point at the position we're copying into*/
  47.     
  48.     s++; /*point at 1st char after length byte*/
  49.     
  50.     while (lensource--) 
  51.         *d++ = *s++;
  52.     
  53.     return (true);
  54.     } /*IACpushstring*/
  55.     
  56.     
  57. Boolean IACgetlongattr (AppleEvent *event, AEKeyword key, DescType type, long *pattr) {
  58.     
  59.     register OSErr ec;
  60.     Size actualsize;
  61.     
  62.     ec = AEGetAttributePtr (event, key, type, &type, (Ptr) pattr, sizeof (long), &actualsize);
  63.     
  64.     IACglobals.errorcode = ec;
  65.     
  66.     return (ec == noErr);
  67.     } /*IACgetlongattr*/
  68.  
  69.  
  70. Boolean IACbreakembrace (void) {
  71.     
  72.     /*
  73.     return true if the user is holding down the cmd, option and shift keys.
  74.     */
  75.     
  76.     register Ptr p;
  77.     KeyMap keys;
  78.     
  79.     GetKeys (keys);
  80.     
  81.     p = (Ptr) keys; 
  82.     
  83.     return (BitTst (p, 63) && BitTst (p, 48) && BitTst (p, 61));
  84.     } /*IACbreakembrace*/
  85.  
  86.  
  87. pascal short IACwaitroutine (EventRecord *ev, long *sleep, RgnHandle *mousergn) {
  88.     
  89.     /*
  90.     called by the AppleEvent manager during AESend to give the user a chance to 
  91.     break out of a wait loop.
  92.     */
  93.     
  94.     if (IACbreakembrace ()) /*user holding down cmd, option and shift keys*/
  95.         return (-1); /*stop waiting*/
  96.     
  97.     if (IACglobals.waitroutine == nil) /*keep waiting*/
  98.         return (0);
  99.     
  100.     return ((*IACglobals.waitroutine) (ev));
  101.     } /*IACwaitroutine*/
  102.     
  103.  
  104.  
  105.     
  106.  
  107.  
  108.